package zb.blog.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zb.blog.base.bean.Result;
import zb.blog.service.INavBarService;

import java.util.List;
import java.util.Map;

/**
 * @Author: BinZhang
 * @Date: 2018/5/1 15:23
 * @Description:导航菜单相关
 */
@Controller
@RequestMapping("/navbar")
public class NavBarController {
    @Autowired
    private INavBarService iNavBarService;

    /**
     * @Author: BinZhang
     * @Date: 2018/5/7 22:40
     * @Description:获取菜单,用于前台的显示，只显示被启用的菜单
     */
    @RequestMapping("/getNavBarByEnable")
    @ResponseBody
    public List<Map<String, Object>> getNavBarByEnable() {
        return iNavBarService.getNavBarByEnable(1);//1：启用 0：不启用
    }

    /**
     * @param enable : null : 全部，1：启用， 0：不启用
     * @Author: BinZhang
     * @Date: 2018/5/11 10:20
     * @Description:获取菜单，用于后台的维护
     */
    @RequestMapping("/back/getNavBarAll")
    @ResponseBody
    public List<Map<String, Object>> getNavBarAll(Integer enable) {
        return iNavBarService.getNavBarByEnable(enable);
    }

    /**
     * @Author: BinZhang
     * @Date: 2018/5/11 16:07
     * @Description:更新状态
     */
    @RequestMapping("/back/updateStatus")
    @ResponseBody
    public Result updateStatus(Integer status, Integer id) {
        return iNavBarService.updateStatus(status, id);
    }

    @RequestMapping("/back/getNavBarToZtree")
    @ResponseBody
    public List<Map<String, Object>> getNavBarToZtree() {
        return iNavBarService.getNavBarToZtree(1);
    }
}
